
from flask import request
from db_dto_helper import create_app
from db_dto_helper.views import connect
from db_dto_helper.views import home
from db_dto_helper.views import dto_service
from db_dto_helper.views import aiservice
from db_dto_helper.views import dataset
from flask_cors import CORS
from gevent import pywsgi




app = create_app()

def before_request():
    path = request.path
    if path.startswith('/static'):
        print(f'path is { request.path }')


# 按装订区域中的绿色按钮以运行脚本。
if __name__ == '__main__':
    CORS(app, supports_credentials=True)
    app.register_blueprint( home.home)
    app.register_blueprint( connect.conn_api,url_prefix=connect.url_prefix)
    app.register_blueprint( dto_service.dto_api,url_prefix=dto_service.url_prefix)
    app.register_blueprint( aiservice.aiapi,url_prefix=aiservice.url_prefix)
    app.register_blueprint( dataset.setapi,url_prefix=dataset.url_prefix)
    app.before_request(before_request)
    app.run(debug=True)
    # 生产环境使用下面代码
    #server = pywsgi.WSGIServer(('0.0.0.0',5000),app)
    #server.serve_forever()


